package it.traveldream.beans;

import it.traveldream.dto.UserDTO;
import it.traveldream.exceptions.InvalidCredentialsException;
import it.traveldream.utils.Validator;

import javax.ejb.Local;

/**
 * 
 * @author Flavio Ferrara
 * AccountManagerInterface declares and describes available functions that the client can call
 * in order to handle user accounts.
 * 
 * This interface will be implemented by one or more Enterprise Java Beans.
 */

@Local
public interface AccountFactoryInterface {
	/**
	 * Checks if the credentials choosen by the user respects constraints defined by
	 * the implementation of Validator passed as argument
	 * 
	 * @param user The credentials choosen by the user
	 * @param validator A concrete object that implements Validator interface
	 * @throws InvalidCredentialsException
	 * @return True if credentials are valid. False otherwise
	 */
	public boolean validateCredentials(UserDTO user, Validator validator);
	
	/**
	 * Permanently records in Persistence tier a new Customer
	 * Customer's credentials are validated
	 * @param user The credentials of the just entered Customer
	 */
	public void saveCustomer(UserDTO user) throws InvalidCredentialsException;
	
	/**
	 * Returns the information regarding the 
	 * customer who make this call
	 * @return Customer information
	 */
	public UserDTO getCurrentCustomer();

}
